package cloud.consumer.order.controller;

import cloud.consumer.order.service.ProductService;
import clould.springcloud.entity.CommontsResult;
import clould.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

@RestController
@RequestMapping("order")
public class OrderController {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private CommontsResult commontsResult;
    @Autowired
    private ProductService productService;

    @PostMapping("/insertOrder")
    public CommontsResult insertOrder(@RequestBody Payment payment){
        return commontsResult.success(restTemplate.postForObject("http://CLOUD-PAYMENT-SERVICE/PaymentController/paymentInsert", payment, CommontsResult.class));
    }
    @GetMapping("getPaymentById")
    public Object getPaymentById(){
//        return productService.getInfo();
        return restTemplate.getForObject("http://CLOUD-PAYMENT-SERVICE/PaymentController/findPaymentById",Object.class);
    }
}
